<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<title>设备检修</title>
		<link rel="stylesheet"
			href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
iframe {
	width: 100%;
	height: 600px;
}

.ui-datalist-empty-message {
	min-height: 100px;
}

.ui-datalist-content {
	min-height: 100px;
}

.purple {
	background-color: #ef8519;
}

.green {
	background-color: #4cb9da;
}

.red {
	background-color: #57ce49;
}

.ui-datatable-scrollable-header-box {
	margin-left: 0px;
	margin-right: 15px !important;
}
.alertbox {
    position: relative;
    border-radius: 3px;
    background: #ffffff;
    border-top: 3px solid #d2d6de;
    margin-bottom: 5px;
    width: 100%;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}
</style>
	</ui:define>
	<ui:define name="content">
		<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
			<p:commandButton value="是" type="button"
				styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
			<p:commandButton value="否" type="button"
				styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
		</p:confirmDialog>
		<div id="headDiv" class="box box-solid with-border">
			<h:form id="headForm">
				<div class="box-header" id="queryDiv">
					<p:outputLabel value="开关名称：" />
					<p:autoComplete scrollHeight="400" id="switchId"
						style="margin-right:5px;"
						value="#{equipmentTripDetailController.switchName}"
						completeMethod="#{equipmentTripDetailController.completeSwitchName}">
					</p:autoComplete>
					<p:outputLabel value="一次设备：" />
					<p:autoComplete scrollHeight="400" id="lineId"
						style="margin-right:5px;"
						value="#{equipmentTripDetailController.lineName}"
						completeMethod="#{equipmentTripDetailController.completeLineName}">
					</p:autoComplete>
					<p:outputLabel value="电压等级：" />
					<h:selectOneMenu value="#{equipmentTripDetailController.voltage}"
						id="volId" style="width:100px;margin-right:10px;height:30px">
						<f:selectItem itemValue="" itemLabel="" />
						<f:selectItems
							value="#{equipmentTripDetailController.voltageClasses}" />
					</h:selectOneMenu>
					<p:outputLabel for="popup1" value="分闸时间：" />
					<p:calendar id="popup1" navigator="true"
						value="#{equipmentTripDetailController.queryDate1}"
						pattern="yyyy-MM-dd" maxdate="Date()" size="14" />
					<p:outputLabel for="popup2" value="至 " />
					<p:calendar id="popup2" navigator="true"
						value="#{equipmentTripDetailController.queryDate2}"
						pattern="yyyy-MM-dd" maxdate="Date()" size="14" />
					<p:commandButton value="查询"
						style="marin-right:10px;margin-left:10px;"
						action="#{equipmentTripDetailController.initTable()}"
						icon="ui-icon-search"
						update="form:dataTb headForm:toolbar headForm:msgs"
						oncomplete="getTableScrollHeight();">
					</p:commandButton>
					<p:commandButton icon="ui-icon-refresh" value="重置"
						actionListener="#{equipmentTripDetailController.reset()}"
						style="margin-left:5px;"
						update="form:dataTb headForm:toolbar switchId lineId volId popup1 popup2"
						oncomplete="getTableScrollHeight();" />
				</div>
				<div id="toolbarDiv">
					<p:toolbar id="toolbar">
						<p:growl id="msgs" showDetail="true" />
						<f:facet name="left">
							<p:commandButton value="新建" icon="fa fa-plus"
								oncomplete="PF('createDlg').show()"
								actionListener="#{equipmentTripDetailController.preCreate()}"
								rendered="#{s:hasPermission(session,'bhyx_sbtzxq_xj')}"
								update="creatForm:createDlg " />
							<p:commandButton value="编辑" id="editbtn" icon="fa fa-pencil"
								oncomplete="PF('createDlg').show()"
								rendered="#{s:hasPermission(session,'bhyx_sbtzxq_bj')}"
								actionListener="#{equipmentTripDetailController.preUpate()}"
								update="creatForm:createDlg "
								disabled="#{equipmentTripDetailController.selectTrip == null}" />
							<p:commandButton value="删除" id="delbtn" icon="fa fa-trash"
								update="form:dataTb headForm:toolbar headForm:msgs"
								actionListener="#{equipmentTripDetailController.delete()}"
								rendered="#{s:hasPermission(session,'bhyx_sbtzxq_sc')}"
								disabled="#{equipmentTripDetailController.selectTrip == null}">
								<p:confirm header="提示" message="确定删除该记录吗?" icon="ui-icon-alert" />
							</p:commandButton>
						</f:facet>
					</p:toolbar>
				</div>
			</h:form>
		</div>
		<div id="infoDiv" class="box box-solid with-border">
			<h:form id="form">
				<p:dataTable var="item" id="dataTb"
					value="#{equipmentTripDetailController.model}" rowKey="#{item.id}"
					emptyMessage="无记录" lazy="true" paginator="true"
					paginatorPosition="bottom" scrollable="true"
					paginatorTemplate="{Customer} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rows="20" rowsPerPageTemplate="20,50,100">
					<p:ajax event="rowSelectRadio"
						listener="#{equipmentTripDetailController.onRowSelect}"
						update="headForm:toolbar form:dataTb " />
					<f:facet name="{Customer}">
						<p:outputLabel
							value="总计：#{equipmentTripDetailController.model.rowCount}条纪录"
							style="margin-right:20px" />
					</f:facet>
					<p:column selectionMode="single" width="5%"
						style="text-align:center" />
					<p:column headerText="序号" style="width:60px;">
						<h:outputText
							value="#{equipmentTripDetailController.getIndex(item)}" />
					</p:column>
					<p:column headerText="开关名称">
						<h:outputText value="#{item.switchName}" />
					</p:column>
					<p:column headerText="一次设备">
						<h:outputText value="#{item.lineName}" />
					</p:column>
					<p:column headerText="厂站名称1">
						<h:outputText value="#{item.stationName1}" />
					</p:column>
					<p:column headerText="厂站名称2">
						<h:outputText value="#{item.stationName2}" />
					</p:column>
					<p:column headerText="分闸时间">
						<h:outputText value="#{item.tripTime}" />
					</p:column>
					<p:column headerText="电压等级">
						<h:outputText value="#{item.voltageClass}" />
					</p:column>
					<p:column style="text-align:center;">
						<p:commandLink value="详情"
							style="text-decoration:underline;color:red;"
							oncomplete="PF('alertDialog').show()" />
					</p:column>
<!-- 					<p:column style="text-align:center;">
						<p:commandLink value="详情"
							style="text-decoration:underline;color:red;"
							oncomplete="PF('detailDialog').show()"
							update="dialogFrom:detailDialog"
							actionListener="#{equipmentTripDetailController.getYXDetail(item)}" />
					</p:column> -->
				</p:dataTable>
			</h:form>
			<h:form id="creatForm">
				<p:dialog widgetVar="createDlg"
					header="#{equipmentTripDetailController.current.id==null?'新建':'编辑'}"
					modal="true" id="createDlg" width="400" height="500">
					<p:toolbar>
						<f:facet name="left">
							<p:commandButton id="createSaveBtn" value="保存"
								style="float: right;" icon="fa fa-floppy-o"
								update="form:dataTb headForm:msgs"
								actionListener="#{equipmentTripDetailController.save()}"
								oncomplete="PF('createDlg').hide();getTableScrollHeight();" />
						</f:facet>
					</p:toolbar>
					<p:panelGrid columns="2">
						<h:outputText value="线路名称" />
						<p:autoComplete dropdown="true" scrollHeight="400" id="linename"
							value="#{equipmentTripDetailController.current.lineName}"
							completeMethod="#{equipmentTripDetailController.completeLineName}"
							required="true" requiredMessage="线路名称为必填">
							<p:ajax update="startST endST lineID" event="itemSelect"
								listener="#{equipmentTripDetailController.autoCompleteLineStation}" />
						</p:autoComplete>
						<h:outputText value="线路ID" />
						<p:inputText id="lineID" readonly="true"
							value="#{equipmentTripDetailController.lineId}" required="true"
							requiredMessage="线路ID为必填" />
						<h:outputText value="厂站名称1" />
						<p:inputText id="startST" readonly="true"
							value="#{equipmentTripDetailController.startStation}" />
						<h:outputText value="厂站名称2" />
						<p:inputText id="endST" readonly="true"
							value="#{equipmentTripDetailController.endStation}" />
						<h:outputText value="分闸时间" />
						<p:calendar navigator="true" pattern="yyyy-MM-dd HH:mm:ss"
							value="#{equipmentTripDetailController.current.tripTime}"
							required="true" requiredMessage="分闸时间为必填" />
						<h:outputText value="开关名称" />
						<p:autoComplete scrollHeight="400"
							value="#{equipmentTripDetailController.current.switchName}"
							completeMethod="#{equipmentTripDetailController.completeSwitchName}"
							dropdown="true" />
						<h:outputText value="电压等级" />
						<p:autoComplete
							value="#{equipmentTripDetailController.current.voltageClass}"
							completeMethod="#{equipmentTripDetailController.completeVoltageClass}"
							dropdown="true" required="true" requiredMessage="电压等级为必填" />
					</p:panelGrid>
				</p:dialog>
			</h:form>
			<h:form id="dialogFrom">
				<ui:include src="/ui/dataview/daily/equipmentTripdetailDialog.xhtml"></ui:include>
			</h:form>
			<h:form id="AlertFrom">
				<ui:include src="/ui/dataview/daily/equipmentTripdetailAlert.xhtml"></ui:include>
			</h:form>
		</div>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/singleScrollTable.js" />
	</ui:define>
</ui:composition>